
const fs = require('fs')
const path = require('path');

function traverseDir(dir,list = [],type = '') {
    //type folder or file 返回的类型返回文件夹还是文件
    fs.readdirSync(dir).forEach(file => {  
      const filePath = path.join(dir, file);  
      const stats = fs.statSync(filePath);
      if (stats.isDirectory()) {
        type === 'folder' && list.push(filePath)
        traverseDir(filePath,list,type);
      } else {
        type === 'file' && list.push(filePath)
      }
    });
}

module.exports = {
    traverseDir:traverseDir
}